package ynu.edu.dao;

import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;
import ynu.edu.po.User;
import org.springframework.data.jpa.repository.JpaRepository;
import java.util.List;

@Repository
public interface IUserDao extends JpaRepository<User, String> {

    // 根据用户 ID 和密码查询
    User findUserByIdAndPassword(String id, String password);

    // 根据年龄范围、性别和学生姓名（模糊匹配）查询
    List<User> findStudentsByAgeBetweenAndSexIsAndStuNameContaining(Integer minAge, Integer maxAge, Boolean sex, String name);

    // 使用 @Query 注解编写自定义 JPQL 查询
    @Query("select u from User u where u.age between :min and :max and u.sex = :sex and u.stuName like %:name%")
    List<User> findStudentsByAgeAndSexAndName(@Param("min") Integer minAge,
                                              @Param("max") Integer maxAge,
                                              @Param("sex") Boolean sex,
                                              @Param("name") String name);

    User findStudentByStuIdAndPassword(Long aLong, String password);


    // 其他方法...
}
